function foreReload(){
	$(".dynamic-html").append("<div class='gray_box' style='z-index: 109; width: 100%; height: 100%;background: none repeat scroll 0 0 #000000;'><span style='background:url(Public/img/voice/loading.gif);display:block;width:32px;height:32px;margin:250px auto;'></span></div>");
	var loadtime = setInterval(function(){
		if(document.readyState == "complete"){
			$(".dynamic-html").empty();
			clearInterval(loadtime);
		}
	},1000);
}
function load(){
	$(".ajax-loading").ajaxStart(function(){
		$(this).fadeIn();
	}).ajaxComplete(function(){
		$(this).fadeOut();
	});
}
function IsNum(e) {
	var k = window.event ? e.keyCode : e.which;
	if (((k >= 48) && (k <= 57)) || k == 8 || k == 0) {
	} else {
		$.globalMessenger().post('只能输入数字');
		if (window.event) {
			window.event.returnValue = false;
		}
		else {
			e.preventDefault(); //for firefox 
		}
	}
}
//获取input中的value(根据name属性)
function getInputValueByName(name){
	var $name = name;
	return $("input[name='"+$name+"']").val();
}
//获取input中的value(根据id属性)
function getInputValueById(id){
	return $("#"+id).val();
}
//显示下拉菜单
function dropdownMenu(id){
        if($("#"+id).css("display") == "block"){
                $("#"+id).css("display","none");
                return;
        }
        $("#"+id).css("display","block");
}
//点击下拉菜单中的某一选项之后，下拉菜单消失
function fadeOutMenu(){
        $(".dropdown-menu").css("display","none");
}
//load页面
function MP(id,url){
	$("#"+id).load(url);
	$(".voice-right-content").css("display","none");
	$(".ready-move-contacters").hide().find("ul").empty();
	moveContacterId.splice(0,moveContacterId.length);
	id = 0;
	$(".contact-empty").css("display","block");
}
//显示短信/联系人信息
function showSmsContent(url,id){
	if($(".voice-right-content").css("display") == "block"){
		$(".voice-right-content").css("display","none");
	}
	$(".contact-empty").css("display","none");
	$(".ready-move-contacters").hide().find("ul").empty();
	$(".voice-right-content").load(url,{contacter_id:id},function(){$(".voice-right-content").css("display","block");});
}
//监听Enter事件
function focusEnter(className,url,smsContent){
	$("."+className).keypress(function(event){
		if(event.which == 13){
			alert(date());
			//$.post(url,{smsContent:smsContent},function(json){
			//});
		}
	});
}
//发送短消息
function sendSms(url,smsContent){
	//$.post(url,{smsContent:smsContent},function(json){
	//	alert(json.info);
	//});
}
//清除动态html
function clearDynamicHtml(){
	$(".dynamic-html").empty();
}
//核对taken是否合法
function checkIsValid(){
	$(".divBox p").each(function(i){
		if($(this).html() == "已登录"){
			alert("1");
		}
	});
}
//充值
function purchaseContacts(url,category_id,money){
	$.post(url,{category_id:category_id,amount:money},function(json){
		if(json.status == 1){
			$.remind("提示",json.info);
		}else{
			$.remind("提示",json.info);
		}
	});
}
/**********addcontact start************/
//选择分类
	function selectGroup(){
		if($('.group').css("display")=="block"){
			$(".group").fadeOut(5);
		}
		$(".down").toggleClass('up');
		$('.group').css('display','block');
	}
	//监听select中的被容变化
	function nextSelectMenu(url,value,childName){
		if(value == "-1"){$("select[name='"+childName+"']").remove();return;}
		if(value == "-2"){$("select[name='"+childName+"'],select[name='child_child_name']").remove();return;}
		if(childName == "child_name" && $("select[name='child_child_name']").length != 0){
			$("select[name='child_child_name']").remove();
		}
		value=value.split(',')[0];
		$.getJSON(url,{category_id:value},function(json){
			var innerHtml = "";
			if(json.data.count == 0 || typeof(json.data.count) == "undefined"){
				$("select[name='"+childName+"']").remove();
				return;
			}
			if(json.status == 1){
				for(var i =0 ;i<json.data.count;i++){
					innerHtml = innerHtml + "<option value='"+json.data[i].category_id+","+json.data[i].category_name+"'>"+json.data[i].category_name+"</option>";
				}
				$("select[name='"+childName+"']").remove();
				if(childName == "child_child_name"){
					$(".group-container").append("<select style='margin:5px;width:55%' name='"+childName+"'><option value='-1'>请选择</option>"+innerHtml+"</select>");
					return;
				}
				$(".group-container").append("<select style='width:45%;' name='"+childName+"' onclick='nextSelectMenu(\""+url+"\",value,\"child_child_name\");'><option value='-1'>请选择</option>"+innerHtml+"</select>");
			}
		});
	}
	//向input中插入分组信息
	function insertGroupMsg(){
		if($("select[name='child_name']").length == 0){
			insert($("select[name='parent_name']").val());
			return;
		}
		if($("select[name='child_child_name']").length == 0){
			insert($("select[name='child_name']").val());
			return;
		}
		insert($("select[name='child_child_name']").val());
	}
	function insert(value){
		value = value.split(',');
		$(".group_name").val(value[1]);
		$(".group_id").val(value[0]);
	}
/**********addcontact end************/
//获得当前时间
function timer(num){
	if(num < 10){
		return "0"+num;
	}
	return num;
}
function getTime(){
	var date = new Date();
	var mon = timer(date.getMonth()+1);
	var day = timer(date.getDate());
	return date.getFullYear()+"-"+mon+"-"+day+" "+date.toLocaleTimeString();
}

/*************************************************
*方法：菜单显示消失动作
*参数：id 为需要显示菜单的属性id，即li的id
*************************************************/
function menuHover(id){
	$("#"+id+" div").show();
}
function menuBlur(id){
	$("#"+id+" div").hide();
}
//关闭移动联系人界面
function closeMoveCotacts(){
	$(".contact-empty").show();
	$(".ready-move-contacters").hide();
	$(".voice-contact-content ul li a").hide();
	$("#contact-content").attr("disabled",false);
	$(".ready-move-contacters").hide().find("ul").empty();
}